﻿using Glorysoft.EAP.Core.Enums;
using Glorysoft.EAP.EAPClient.Model;
using System;
using System.Collections.Generic;
using System.Windows.Media;

namespace Glorysoft.EAP.EAPClient.Common
{
    public class Consts
    {
        static Consts()
        {
        }
        public const string ViewNameSpace = "Glorysoft.EAP.EAPClient";
        public const string RED = "RED";
        public const string GREEN = "GREEN";
        public const string RUNNING = "SkyBlue";
        public const string YELLOW = "YELLOW";
        public static Dictionary<WaferState, Color> WaferStateColorMap = new Dictionary<WaferState, Color>
        {
             {WaferState.Testing ,Colors.Green },
             {WaferState.Waiting ,Colors.Black},
             {WaferState.LoadingDone ,Colors.DarkOrange},
             {WaferState.UnloadingDone ,Colors.DarkOrange},
             {WaferState.Stop ,Colors.Red},
        };
        public static Dictionary<string, string> ViewModelViewMap = new Dictionary<string, string>
        {
            {"MainViewModel","MainWindow"},
            {"LogWindowViewModel","LogWindow"},
            {"LoginViewModel","AdminLogin"},
            {"UserLoginViewModel","UserLogin"},
            {"SelectWaferViewModel","SelectWafer"},
            {"TrackOutLoginViewModel","TrackOutLogin"},
            {"TrackOutLossViewModel","TrackOutLoss"}
        };
        public static Dictionary<string, string> RCYColotMap = new Dictionary<string, string>
        {
            {"RED","4"},
            {"SkyBlue","3"},
            {"GREEN","2"},
            {"YELLOW","1"}
        };
        public static Dictionary<MessageType, Color> MsgColorMap = new Dictionary<MessageType, Color>
        {
             {MessageType.Normal ,Colors.Black},
             {MessageType.Info ,Colors.Black},
             {MessageType.Warning,Colors.Orange},
             {MessageType.Error,Colors.Red},
             {MessageType.Alarm,Colors.Red},
             {MessageType.ParamValue ,Colors.Orange},
             {MessageType.Conn ,Colors.Green}
        };
        public static Dictionary<ProcessState, Color> LotStateColorMap = new Dictionary<ProcessState, Color>
        {
            {ProcessState.UnKnow, Colors.Gray},
            {ProcessState.TrackOut , Colors.SkyBlue},
            {ProcessState.Waitting , Colors.Yellow},
            {ProcessState.PPSelectCmd , Colors.SkyBlue},
            {ProcessState.TrackIn , Colors.SkyBlue},
            {ProcessState.CheckingRecipe , Colors.MediumSeaGreen},
            {ProcessState.RequestRmsCompare , Colors.LightPink},
            {ProcessState.Running ,Colors.SkyBlue},
            {ProcessState.Alarm ,Colors.DarkRed},
            {ProcessState.Completed, Colors.DodgerBlue},
            {ProcessState.CarrierLoaded ,Colors.PaleTurquoise},
            {ProcessState.LoadCmd, Colors.Khaki},
            {ProcessState.ProcessEnd, Colors.DarkCyan},
            {ProcessState.StartCmd ,Colors.SkyBlue},
            {ProcessState.PPSelect_Fail, Colors.OrangeRed},
            {ProcessState.LoadCmd_Fail ,Colors.OrangeRed},
            {ProcessState.StartCmd_Fail, Colors.OrangeRed},
            {ProcessState.RmsCompared_Fail, Colors.OrangeRed},
            {ProcessState.PPIDList_Fail, Colors.OrangeRed},
            {ProcessState.LoadCmd_Error, Colors.Red},
            {ProcessState.StartCmd_Error, Colors.Red},
            {ProcessState.LoadCmdReceive, Colors.Bisque},
            {ProcessState.StartCmdReceive, Colors.SkyBlue},
            {ProcessState.Warning, Colors.Yellow},
            {ProcessState.ProcessEnd_Error ,Colors.Red},
            {ProcessState.UnLoadCmd, Colors.Indigo},
            {ProcessState.UnLoadCmdReceive, Colors.Orchid},
            {ProcessState.UnLoadCmd_Fail ,Colors.OrangeRed},
            {ProcessState.PPSelectCmdReceive ,Colors.SkyBlue},
            {ProcessState.TrackIn_Fail, Colors.OrangeRed},
            {ProcessState.TrackOut_Fail ,Colors.OrangeRed},
            {ProcessState.ProceedCarrier1stCmd ,Colors.Khaki},
            {ProcessState.ProceedCarrier2ndCmd ,Colors.MediumOrchid},
            {ProcessState.ProceedCarrier1stCmd_Fail ,Colors.OrangeRed},
            {ProcessState.ProceedCarrier2ndCmd_Fail ,Colors.OrangeRed},
            {ProcessState.ProceedCarrier1stCmdReceive ,Colors.Bisque},
            {ProcessState.ProceedCarrier2ndCmdReceive ,Colors.CadetBlue},
            {ProcessState.CheckProcessJobSpace ,Colors.SteelBlue},
            {ProcessState.CheckProcessJobSpace_Fail ,Colors.OrangeRed},
            {ProcessState.CheckControlobSpace ,Colors.Ivory},
            {ProcessState.CheckControlJobSpace_Fail ,Colors.CadetBlue},
            {ProcessState.CreateProcessJobCmd ,Colors.Honeydew},
            {ProcessState.CreateProcessJobCmd_Fail ,Colors.OrangeRed},
            {ProcessState.CreateProcessJobCmdReceive ,Colors.LightSalmon},
            {ProcessState.CreateControlJobCmd ,Colors.Pink},
            {ProcessState.CreateControlJobCmd_Fail ,Colors.OrangeRed},
            {ProcessState.CreateControlJobCmdReceive ,Colors.SandyBrown},
            {ProcessState.CreateProcessJob_Error ,Colors.OrangeRed},
            {ProcessState.CreateControlJob_Error ,Colors.OrangeRed},
            {ProcessState.CheckWaferQty_Fail ,Colors.OrangeRed},
            {ProcessState.CheckWaferQtyOK ,Colors.LemonChiffon},
            {ProcessState.RFID_Fail ,Colors.OrangeRed},
            {ProcessState.RFID_OK ,Colors.Olive},
            {ProcessState.ScanCmd ,Colors.Khaki},
            {ProcessState.ScanCmdReceive ,Colors.Bisque},
            {ProcessState.ScanCmd_Fail ,Colors.OrangeRed},
            {ProcessState.Scan_Error ,Colors.OrangeRed},
            {ProcessState.ScanReport ,Colors.PaleTurquoise},
            {ProcessState.GoRemoteCmd ,Colors.MediumAquamarine},
            {ProcessState.GoRemoteCmdOK ,Colors.MediumOrchid},
            {ProcessState.GoRemoteCmd_Fail ,Colors.OrangeRed},
            {ProcessState.PPIDListOK,Colors.MediumPurple},
            {ProcessState.GetLotInfoOK ,Colors.SkyBlue},
            {ProcessState.GetLotInfoFail ,Colors.OrangeRed},
        };
        public static Dictionary<ProcessState, string> RGYColorMap = new Dictionary<ProcessState, string>
        {
            {ProcessState.UnKnow  , RED},
            {ProcessState.TrackOut , YELLOW},
            {ProcessState.Waitting , GREEN},
            {ProcessState.PPSelectCmd ,GREEN},
            {ProcessState.TrackIn , GREEN},
            {ProcessState.CheckingRecipe , GREEN},
            {ProcessState.RequestRmsCompare , GREEN},
            {ProcessState.Running ,RUNNING},
            {ProcessState.Alarm ,YELLOW},
            {ProcessState.Completed, YELLOW},
            {ProcessState.CarrierLoaded ,GREEN},
            {ProcessState.LoadCmd, GREEN},
            {ProcessState.ProcessEnd, GREEN},
            {ProcessState.StartCmd ,GREEN},
            {ProcessState.PPSelect_Fail, RED},
            {ProcessState.LoadCmd_Fail ,RED},
            {ProcessState.StartCmd_Fail, RED},
            {ProcessState.RmsCompared_Fail, RED},
            {ProcessState.PPIDList_Fail, RED},
            {ProcessState.LoadCmd_Error, RED},
            {ProcessState.StartCmd_Error,RED},
            {ProcessState.LoadCmdReceive, GREEN},
            {ProcessState.StartCmdReceive, GREEN},
            {ProcessState.Warning, RED},
            {ProcessState.ProcessEnd_Error ,RED},
            {ProcessState.UnLoadCmd, GREEN},
            {ProcessState.UnLoadCmdReceive, GREEN},
            {ProcessState.UnLoadCmd_Fail ,RED},
            {ProcessState.PPSelectCmdReceive ,GREEN},
            {ProcessState.TrackIn_Fail, RED},
            {ProcessState.TrackOut_Fail ,RED},
            {ProcessState.ProceedCarrier1stCmd ,GREEN},
            {ProcessState.ProceedCarrier2ndCmd ,GREEN},
            {ProcessState.ProceedCarrier1stCmd_Fail ,RED},
            {ProcessState.ProceedCarrier2ndCmd_Fail ,RED},
            {ProcessState.ProceedCarrier1stCmdReceive ,GREEN},
            {ProcessState.ProceedCarrier2ndCmdReceive ,GREEN},
            {ProcessState.CheckProcessJobSpace ,GREEN},
            {ProcessState.CheckProcessJobSpace_Fail ,RED},
            {ProcessState.CheckControlobSpace ,GREEN},
            {ProcessState.CheckControlJobSpace_Fail ,RED},
            {ProcessState.CreateProcessJobCmd ,GREEN},
            {ProcessState.CreateProcessJobCmd_Fail ,RED},
            {ProcessState.CreateProcessJobCmdReceive ,GREEN},
            {ProcessState.CreateControlJobCmd ,GREEN},
            {ProcessState.CreateControlJobCmd_Fail ,RED},
            {ProcessState.CreateControlJobCmdReceive ,GREEN},
            {ProcessState.CreateProcessJob_Error ,RED},
            {ProcessState.CreateControlJob_Error ,RED},
            {ProcessState.CheckWaferQty_Fail ,RED},
            {ProcessState.CheckWaferQtyOK ,GREEN},
            {ProcessState.RFID_Fail ,RED},
            {ProcessState.RFID_OK ,GREEN},
            {ProcessState.ScanCmd ,GREEN},
            {ProcessState.ScanCmdReceive ,GREEN},
            {ProcessState.ScanCmd_Fail ,RED},
            {ProcessState.Scan_Error ,RED},
            {ProcessState.ScanReport ,GREEN},
            {ProcessState.GoRemoteCmd ,GREEN},
            {ProcessState.GoRemoteCmdOK ,GREEN},
            {ProcessState.GoRemoteCmd_Fail ,RED},
            {ProcessState.PPIDListOK,GREEN}
        };

        public static Dictionary<string, string> Translator = new Dictionary<string, string>
        {
            #region 控件描述
            { "Btn_Refrensh","刷新:Refrensh"},
            { "Btn_Min","最小化:Min"},
            { "Btn_Exit","退出:Exit"},
            { "Btn_Chinese","中文:Chinese"},
            { "Btn_English","英语:English"},
            { "Btn_OK","确认:OK"},
            { "Btn_Yes","是:Yes"},
            { "Btn_No","否:No"},
            { "Btn_Cancel","取消:Cancel"},
            { "Lbl_EAPSignal","EAP信号灯:EAP Signal"},
            { "Lbl_EAPStateonline","OnLine:OnLine"},
            { "Lbl_EAPStateoffline","OnLine:OnLine"},
            { "Lbl_EQPSignal","设备信号灯:EQP Signal"},
            { "Lbl_OCRSignal","Probe信号灯:Probe Signal"},
            { "Lbl_DaemonSignal","Tester信号灯:Tester Signal"},
            { "Tab_ScanInfo","扫描信息:Scan Information"},
            { "Tab_ScanHis","扫描历史:Scan History"},
            { "Lbl_OPID","工号:OPID"},
            { "Lbl_EQPID","设备:EQPID"},
          //{ "Lbl_CarrierID","载具:CARRIER"},
          //{ "Lbl_LOTID","LOT:LOT ID"},
            { "Tip_Scanlotinfo","获取批次信息:LotInfo"},
            { "Tip_ScanLisen","用户名登录:User Admin"},
            { "Btn_lotOK","确定:Confirm"},
            { "Btn_lotEnd","出站:TrackOut"},
            { "Btn_login","登录:Login"},
            { "Txt_eaprun","EAP代操中，请勿操作测试机电脑与此电脑！:EAP代操中，请勿操作测试机电脑与此电脑！"},
            { "Btn_loginout","登出:LoginOut"},
            { "Btn_Clean","清空:Clean"},
          //{ "Btn_TrackOut","批次结束:LotEnd"},
            { "Tip_Clean","清空扫描信息:Clean Scan Info"},
            { "Tip_TrackOut","手动出站: TrackOut By User"},
            { "Tip_OnOffline","作业模式: Process Mode"},
            { "Lbl_State","状态:State"},
            { "Lbl_Lotid","批号:LotId"},
            { "Lbl_ProberCardid","探卡:ProberCardId"},
            { "Lbl_Alignment","自动对针:Needle Alignment"},
            { "Lbl_TestSiteMode","测试模式:Test Mode"},
            { "Lbl_chipselect","自动选片:Screen WaferId"},
            { "Radio_AutoSelectWaferTest","是:Y"},
            { "Radio_ManualSelectWaferTest","否:N"},
            { "Radio_AlignmentYes","是:Y"},
            { "Radio_AlignmentNo","否:N"},
            { "Radio_TestModeSingle","单 Site:单 Site"},
            { "Radio_TestModeNoSingle","8 Site:8 Site"},
            { "Radio_TestModeNoSingleS","4 Site:4 Site"},
            { "Lbl_Carrier","载具:CARRIER"},
            { "Lbl_Qty","数量:Quantity"},
            { "Lbl_Product","产品:Product"},
            { "Lbl_TestID","测试片:TestID"},
            { "Lbl_Step","站点:Step"},
            { "Lbl_TesterProgram","Tester程序:Tester Program"},
            { "Lbl_ProgramPath","程序路径:Program Path "},
            { "Lbl_UserId","用户:UserId"},
            { "Lbl_ProberRecipe","Prober配方:Prober Recipe"},
            { "Lbl_Priority","优先级:Priority"},
            { "Lbl_StageId","工步:Stage Id"},
            { "Lbl_Expand","展开全部:Show All"},
            { "Lbl_Copythis","复制此条:Copy This"},
            { "Lbl_Copyall","全部复制:Copy All"},
            { "Lbl_deletethis","删除此条:Delete This"},
            { "Lbl_clearall","清空全部:Clear All"},
           #endregion
            #region MessageBox描述
            
            { "Msg_Loading","加载中:Loading"},
            { "Msg_LoadComplete","完成:Completed"},
            { "Msg_CurTme","当前时间:Current Time"},
            { "Msg_StartTime","启动时间:Start Time"},
            { "Msg_Exit","是否确定退出EAP？:Are you sure to exit ?"},
            { "Msg_online","请确认切换作业模式为:Are you sure to change mode "},
            { "Msg_Confirm","请确定当前信息：:Please confirm："},
            { "Msg_ConfirmInfo","确认信息:Confirm Info"},
            { "Msg_ConfirmToResetTester","请关闭Tester主程序后再执行确认！:Please close the tester main program before executing the confirmation"},
            { "Msg_RealtimeInfo","实时信息:Real-time Information"},
            { "Msg_WaferInfo","晶圆信息:Wafer Information"},
            { "Msg_LotidInputInfo","请输入LotId！:Please Input LotId!"},
            { "Msg_ProbercarIdInputInfo","请输入ProbercardId！:Please Input ProbercardId!"},
            { "Msg_UserIdInputInfo","请输入用户工号！:Please Input UserID!"},
            { "Msg_ScanEQPID","请先扫描设备!:Please scan the equipment first!"},
            { "Msg_UserAdmin","请先点击登录按钮，登录用户！:Please Press the Login Button First, Login UserId !"},
            { "Msg_SNSelect","你选择的SN有{0}:You have Select SN is{0} "},
            { "Msg_UserPwdInputInfo","请输入用户密码!:Please Input Password!"},
            { "Msg_GetLotinfo","获取批次失败，请检查批次信息!:LotId or ProbecardId is incorrect, please check!"},
            { "Msg_GetLotinfoByType2","获取批次失败，请检查批次信息2!:LotId is incorrect, please check!"},
            { "Msg_GetLotinfo_fail","获取批次失败，请检查批次当前的状态!:Check lot status in MES!"},
            { "Msg_Loginfail","用户名或密码不正确，请检查登陆信息!:Userid or password is incorrect, please check!"},
            { "Msg_RemovelotManually","是否确定手动清除该作业批次?:Confirm whether the product has been placed?"},
            { "Msg_TrackOutLot","是否确定手动出站?:Confirm Track Out?"},
            { "Msg_CheckPodOK","确认产品{0}是否已放置好?:Are you sure Carrier {0} is set OK?"},
            { "Msg_CheckLotOK","确认批次{0}中产品是否已放置好?:Are you sure Lot {0} is set OK?"},
            { "Msg_CheckTool","治具{0}扫码成!:Tool {0} Scan success!"},
            { "Msg_CheckMaterial","物料{0}扫码成功!:Material {0} Scan success!"},
            { "Msg_DaemonDisConnected","与Daemon连接断开!:Daemon Disconnected!"},
            { "Msg_DaemonConnected","与Daemon连接成功!:Daemon Connected!"},
            { "Msg_GPIBDisConnected","与GPIB连接断开!:GPIB Disconnected!"},
            { "Msg_GPIBConnected","与GPIB连接成功!:GPIB Connected!"},
            { "Msg_UserOrPwdError","二维码：{0}没有对应的规则!: QR code ：{0} is no corresponding rule !"},
            { "Msg_LOSSINFOLIST","未获取到不良品信息，请检查！:LossInfoList is null,Plase Chack!"},
            { "Msg_NotTrickIn","当前批次没有进站，请检查！:Lot Not Trackin,Plase Chack!"},
            { "Msg_TrickOUT","是否确定手动出站？:Are you sure to TrickOUT？ "},
            { "Msg_LoginOK","登录成功.:Login successful. " },
            { "Msg_LoginOutOK","登出成功.:LoginOut successful. " },
            { "Msg_GetLotinfowait","正在获取批次信息，请稍后！:Lot information is loading ,Please wait!"},
            { "Msg_GetLotinfoOK","获取批次信息成功.:Lot information download successful. "},
            { "Msg_WferIdInputInfo","请选择测试ID！:Please select test wafer id!"},
            { "Msg_WferIdInputInfoError","选择的Slot数量比MES中Slot数量大，请再次确认！:  The number of selected slots is larger than that in MES, please confirm again!"},
            { "Msg_CassetteSlotidError","获取MES UnitId失败,请检查MES数据与实物Cassette位置关系!:获取MES UnitId失败,请检查MES数据与实物Cassette位置关系!"},
            { "Msg_CassetteError","人工确认后，当前设备使用的Cassette与MES不一致，请检查更换Cassette!:The cassettes used are inconsistent with MES. Please check and replace the cassettes!"},
            { "Msg_TesterConnectionModeError","人工确认后，当前设备使用的测试机连线方式与MES不一致，请MA进行更换!:The tester connection mode used are inconsistent with MES. Please check and replace!"},
            { "Msg_GetLotSamplePrompts","MES未设定测试Wafer ID,请检查批次信息.:MES未设定测试Wafer ID,请检查批次信息."},
            { "Msg_GetLotRecipeError","Prober Rrcipe不含S11或FM,请联系工程师检查批次MES信息.:Prober Rrcipe不含S11或FM,请联系工程师检查批次MES信息."},
            #endregion
       };
        public static string GetTranslation(string msgName)
        {
            try
            {
                if (RunService.Current.ClientLanguage == "EN")
                {
                    return Consts.Translator[msgName].Split(':')[1];
                }
                else //language=="CN"
                {
                    return Consts.Translator[msgName].Split(':')[0];
                }
            }
            catch (Exception)
            {
                return Consts.Translator[msgName].Split(':')[0];
            }
        }

    }
    public class Defect
    {
        public string DefectCode { get; set; }
        public string DefectName { get; set; }
    }
}
